package main

import (
	"amq/collector"
	"amq/conf"
	"fmt"
	"os"

	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/common/expfmt"
)

func main() {
	if err := conf.LoadConfigFromEnv(); err != nil {
		fmt.Println("Error load config")
		fmt.Println(err)
		os.Exit(1)
	}

	retgistry := prometheus.NewRegistry()
	c := collector.NewAmqCollector()
	err := retgistry.Register(c)
	if err != nil {
		fmt.Println("Error register:", err)
		os.Exit(1)
	}
	mf, err := retgistry.Gather()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	// 如何打印我们mf
	// 编码后直接输出到标准输出
	enc := expfmt.NewEncoder(os.Stdout, expfmt.FmtText)
	for i := range mf {
		enc.Encode(mf[i])
	}
}
